package com.atguigu.spring.ioc.config;

import com.atguigu.spring.ioc.bean.Dog;
import com.atguigu.spring.ioc.bean.Person;
import com.atguigu.spring.ioc.service.UserService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DogConfig {

    // 下面这么写不成功的原因,加载DogConfig时还没加载PersonConfig,或者因为bill也是条件注册,所以一直就没有bill
//    @ConditionalOnMissingBean(name = {"bill"})
//    @ConditionalOnMissingBean(name = "bill")
//    @ConditionalOnMissingBean(value = {UserService.class})
    @ConditionalOnResource(resources = "classpath:haris.hahahha")
    @Bean("dog1")
    public com.atguigu.spring.ioc.bean.Dog dog1() {
        com.atguigu.spring.ioc.bean.Dog dog = new com.atguigu.spring.ioc.bean.Dog();
        dog.setName("dog1");
        return dog;
    }

    @Bean("dog2")
    public com.atguigu.spring.ioc.bean.Dog dog2() {
        com.atguigu.spring.ioc.bean.Dog dog = new com.atguigu.spring.ioc.bean.Dog();
        dog.setName("dog2");
        return dog;
    }

    @Bean("dog3")
    public com.atguigu.spring.ioc.bean.Dog dog3() {
        com.atguigu.spring.ioc.bean.Dog dog = new com.atguigu.spring.ioc.bean.Dog();
        dog.setName("dog3");
        return dog;
    }
}
